package com.blb.demo2;

import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * 负责读的线程
 */
public class ReadRunnable implements Runnable{

    //输入流
    private ObjectInputStream inputStream = null;

    public ReadRunnable(ObjectInputStream inputStream) {
        this.inputStream = inputStream;
    }

    @Override
    public void run() {
        //从输入流中不断读取数据
        try {
            while (true) {
                String message = this.inputStream.readUTF();
                System.out.println(message);
            }
        }catch (IOException ex){
            ex.printStackTrace();
        }
    }
}
